package day06;

import java.util.Scanner;

public class practice2 {
    public static void main(String[] args) {
        //评委打分程序
        double[] scores = a(8);
        double avg = b(scores);
        System.out.println("平均数为："+avg);
    }
    public static double[] a(int n){
        double[] sc = new double[n];
        Scanner scan = new Scanner(System.in);
        for (int i=0;i<sc.length;i++){
            System.out.println("请输入第"+(i+1)+"个评委的分数：");
            sc[i] = scan.nextDouble();
        }
        return sc;
    }
    public static double b(double[] scores){
        double max = scores[0];
        double min = scores[0];
        double total = 0.0;
        for(int i=0;i<scores.length;i++){
            if(scores[i]>max){
                max = scores[i];
            }
            if (scores[i]<min){
                min = scores[i];
            }
            total +=scores[i];
        }
        double avg = (total-min-max)/(scores.length-2);
        return avg;
    }
}

